﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;

/// <summary>
/// Allows a resource summary for an application to be bound using XAML.
/// </summary>
public class ApplicationSummary {
    public string DisplayName { get; set; }
    /// <summary>
    /// Gets or sets the bundles the application contains (formatted).
    /// </summary>
    /// <value>The bundles.</value>
    public List<string> Bundles { get; set; }
    public int TotalElements { get; set; }
    /// <summary>
    /// Gets or sets the completion of resources in each language.
    /// </summary>
    /// <value>The completion map.</value>
    public List<LanguageCompletion> CompletionMap { get; set; }

    /// <summary>
    /// Initializes a new <see cref="ApplicationSummary"/> with the specified name.
    /// </summary>
    /// <param name="name">The display name.</param>
    public ApplicationSummary(string name) {
        this.DisplayName = name;
        this.Bundles = new List<string>();
        this.TotalElements = 0;
        this.CompletionMap = new List<LanguageCompletion>();
    }
}

/// <summary>
/// Shows the resource completion of a language in relation to an application
/// </summary>
public class LanguageCompletion : IComparable {
    /// <summary>
    /// Gets or sets the culture this language represents.
    /// </summary>
    /// <value>The culture this language represents.</value>
    public CultureInfo Culture { get; set; }
    /// <summary>
    /// Gets or sets the ISO3166 code used as the language flag image.
    /// </summary>
    /// <value>The ISO3166 code for the language which is used as the flag image).</value>
    public string Image { get; set; }
    /// <summary>
    /// Gets or sets the number translations available in this language.
    /// </summary>
    /// <value>The num translations.</value>
    public int NumTranslations { get; set; }
    /// <summary>
    /// Initializes a new <see cref="LanguageCompletion"/>.
    /// </summary>
    /// <param name="culture">The culture this language represents.</param>
    /// <param name="image">The number translations available in this language.</param>
    /// <param name="numTranslations">The number translations available in this language.</param>
    public LanguageCompletion(CultureInfo culture, string image, int numTranslations) {
        this.Culture = culture;
        this.Image = image;
        this.NumTranslations = numTranslations;
    }

    /// <summary>
    /// Compares this LanguageCompletion to another object (by English name).
    /// </summary>
    /// <param name="obj"></param>
    /// <returns></returns>
    public int CompareTo(object obj) {
        if(obj is LanguageCompletion) {
            return this.Culture.EnglishName.CompareTo((obj as LanguageCompletion).Culture.EnglishName);
        } else {
            return 1;
        }
    }
}